import { Request } from './index'

class Queue {
  queue: any[] = []
  isPending

  add(reqOptions, resolve, reject) {
    this.queue.push({
      reqOptions,
      resolve,
      reject
    })
  }

  exec() {
    while (this.queue.length > 0) {
      const [item] = this.queue
      Request._request(item.reqOptions, item.resolve, item.reject)
      this.queue.shift()
    }
  }
}

export const queue = new Queue()
